import request from '@/utils/request'

/**
 * 获取员工列表
 * @param {Object} query 查询参数{page：1，size：5}
 * @returns  params
 */
export const getEmpioyeeListAPI = (query) => {
  return request({
    url: '/sys/user',
    params: query,
    method: 'get'
  })
}

/**
 * 删除员工
 * @param {String} empId 员工id
 * @returns Params
 */
export const delEmpolueeAPI = (empId) => {
  return request({
    url: `/sys/user/${empId}`,
    method: 'delete'
  })
}

/**
 * 新增员工(单个)
 * @param {Object} emForm 员工表单
 * @returns Params
 */
export const addEmpolueeAPI = (emForm) => {
  return request({
    method: 'post',
    url: `/sys/user`,
    data: emForm
  })
}

/**
 * 批量上传员工
 * @param {Array} employreeList 员工列表
 * @returns 返回实例对象
 */
export const addEmpolueeBatchAPI = (employreeList) => {
  return request({
    url: '/sys/user/batch',
    data: employreeList,
    method: 'post'
  })
}

/**
 * 获取员工的进本信息
 * @param {String} empId 员工id
 * @returns 员工基本信息
 */
export const getEmplyeeInfoAPI = (empId) => {
  return request({
    url: `/sys/user/${empId}`
  })
}

/**
 * 修改员工密码
 * @param {Object} epmForm 员工基本信息
 * @returns 提示信息
 */
export const updateEmployeeAPI = (epmForm) => {
  return request({
    url: `/sys/user/${epmForm.id}`,
    data: epmForm,
    method: 'put'
  })
}

/**
 * 分配角色
 * @param {String} id 员工id
 * @param {Object} roleIds 角色数组
 * @returns 角色分配结果
 */
export const assignRoleAPI = (id, roleIds) => {
  return request({
    url: '/sys/user/assignRoles',
    data: {
      id,
      roleIds
    },
    method: 'put'
  })
}
